<?php
header("content-type:text/html;charset=utf-8");
include("../config.php");
$domain=$_REQUEST["domain"];//社区域名
$api_token=$_REQUEST["api_token"];//用户的TokenID
$key=$_REQUEST["key"];//用户的密匙
$time=strtotime(date("YmdHis"));//时间戳
$hh=$_REQUEST['hh']?:"\n";//换行符号(默认\n)
function curl($url,$post)
{
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
return curl_exec($curl);
curl_close($curl);
}
//分割
function getsign($param,$key)
{
$signpars="";
ksort($param);
foreach($param as $k=>$v)
{
if("sign"!=$k&&""!=$v)
{
$signpars.="".$k."=".$v."&";
}
}
$signpars=trim($signpars,"&");
$signpars.=$key;
return md5($signpars);
}
$params=["api_token"=>$api_token,"timestamp"=>$time];
$sign=getsign($params,$key);
//分割
$url="".$domain."/api/goods/list";
$post="api_token=".$api_token."&timestamp=".$time."&sign=".$sign."";
$data=curl($url,$post);
$json=json_decode($data,true);
if($json["status"]=="0")
{
echo "".$web["ming"]."API亿乐社区商品列表".$hh."";
echo "━━━━━━━━━".$hh."";
$a=$GET['a']?:'5';//商品数量(默认5个)
$b=$GET['b']?:'1';//页数(默认1)
$c=$a*$b;
$e=preg_match_all('/{"gid":(.*?),"cid":(.*?),"name":"(.*?)","image":"(.*?)","model_id":(.*?),"close":(.*?)}"/',$data,$v);
for ($i=($c-$a); $i <$c ; $i++){
echo "±img=".$value[4][0]."±".$hh."";
echo "商品编号：".$value[1][0]."".$hh."";
echo "商品分组编号：".$value[2][0]."".$hh."";
echo "商品名称：".$value[3][0]."".$hh."";
echo "━━━━━━━━━".$hh."";
}
echo "Tips:".$web["ming"]."API技术支持";
}else{
echo "".$web["ming"]."API亿乐社区订单操作".$hh."";
echo "━━━━━━━━━".$hh."";
echo "".$json["message"]."".$hh."";
echo "━━━━━━━━━".$hh."";
echo "Tips:".$web["ming"]."API技术支持";
}
?>